package com.sbs.gaoxinqutoilet.interfaces;

import android.app.Activity;
import android.os.Handler;
import android.os.Message;

import java.lang.ref.WeakReference;

/**
 * If you change her, tell me
 * sometimes I believe compiler ignores all my comments
 * Created by gyyak46 on 2017/8/14.
 */

public abstract class MyWeakReferenceHandler<T extends Activity> extends Handler {
    private WeakReference<T> weakReferenceActivity = null;

//public WeakReference<T>

    public MyWeakReferenceHandler(T t) {
        this.weakReferenceActivity = new WeakReference<T>(t);
    }

    @Override
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        handleMessage(msg, weakReferenceActivity.get());
    }

    public abstract void handleMessage(Message msg, T t);
}
